/*
 * @Author: 徐汉卿 xuhanqing@imohoo.com
 * @Date: 2023-07-17 18:07:19
 * @LastEditors: 徐汉卿 xuhanqing@imohoo.com
 * @LastEditTime: 2023-07-21 10:54:49
 * @FilePath: /sy-app2/src/utils/needLoginHook.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Taro from "@tarojs/taro";
import { useUserStore } from "@/store/user";
import { getCurrentPageUrlWithArgs } from "./tools";
import { onMounted } from "vue";
import { Router } from "tarojs-router-next";

/**
 * 未登录拦截跳转登录页面
 */
export default () => {
  onMounted(() => {
    //XHQXHQ 
    return

    const state = useUserStore();
    const url = getCurrentPageUrlWithArgs();
    // 通过缓存查询
    // if (!Taro.getStorageSync("Token")) {
    //   Taro.redirectTo({
    //     url: "/pages/login/index",
    //   });
    // }
    // 通过Pinia查询
    console.log("页面拦截判断登录状态:TOKEN ", state.getToken);
    console.log("页面拦截判断登录状态", state.userInfo);
    if (!state.getToken) {
      Taro.reLaunch({
        url: "/pages/login/index",
      });
    }
  });
};


